

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="XiaoMaDing">
  <meta name="keywords" content="">
  
    <meta name="description" content="背景某日，生产告警群中突然出现大量的线上的请求报错，并且收到生产服务的内存阈值告警，通过查看日志、以及监控平台发现，某个容器发生了OOM异常，但整体服务并未完全瘫痪(因为每个服务至少有3~4个容器)，尚有其他节点还在正常对外提供服务 紧急处理此时，需要紧急进行处理，不然一部分流量会一直报错  下线OOM的容器：避免流量再路由到该容器，因为该容器已经OOM，已无法对外正常提供服务 启动新的容器：缓解">
<meta property="og:type" content="article">
<meta property="og:title" content="异常定位：使用MAT分析OOM异常">
<meta property="og:url" content="http://example.com/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/index.html">
<meta property="og:site_name" content="剑出">
<meta property="og:description" content="背景某日，生产告警群中突然出现大量的线上的请求报错，并且收到生产服务的内存阈值告警，通过查看日志、以及监控平台发现，某个容器发生了OOM异常，但整体服务并未完全瘫痪(因为每个服务至少有3~4个容器)，尚有其他节点还在正常对外提供服务 紧急处理此时，需要紧急进行处理，不然一部分流量会一直报错  下线OOM的容器：避免流量再路由到该容器，因为该容器已经OOM，已无法对外正常提供服务 启动新的容器：缓解">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://example.com/index_img/oom.png">
<meta property="article:published_time" content="2023-02-25T13:31:53.000Z">
<meta property="article:modified_time" content="2023-12-26T03:48:16.349Z">
<meta property="article:author" content="XiaoMaDing">
<meta property="article:tag" content="MAT">
<meta property="article:tag" content="OOM">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="http://example.com/index_img/oom.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>异常定位：使用MAT分析OOM异常 - 剑出</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.5-a","typing":{"enable":true,"typeSpeed":40,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":4},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":true,"follow_dnt":false,"baidu":"e0dcc0c9ab8f117bb83579322e04efb8","google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml","include_content_in_search":true};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  

  
    <!-- Baidu Analytics -->
    <script async>
      if (!Fluid.ctx.dnt) {
        var _hmt = _hmt || [];
        (function() {
          var hm = document.createElement("script");
          hm.src = "https://hm.baidu.com/hm.js?e0dcc0c9ab8f117bb83579322e04efb8";
          var s = document.getElementsByTagName("script")[0];
          s.parentNode.insertBefore(hm, s);
        })();
      }
    </script>
  

  

  

  

  

  



  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 60vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>剑出</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/yuzhou.gif') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="异常定位：使用MAT分析OOM异常"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2023-02-25 21:31" pubdate>
          2023年2月25日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          3k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          25 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <h1 id="seo-header">异常定位：使用MAT分析OOM异常</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：7 个月前
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h1 id="背景"><a href="#背景" class="headerlink" title="背景"></a>背景</h1><p>某日，生产告警群中突然出现大量的线上的请求报错，并且收到生产服务的内存阈值告警，通过查看日志、以及监控平台发现，某个容器发生了OOM异常，但整体服务并未完全瘫痪(<code>因为每个服务至少有3~4个容器</code>)，尚有其他节点还在正常对外提供服务</p>
<h1 id="紧急处理"><a href="#紧急处理" class="headerlink" title="紧急处理"></a>紧急处理</h1><p>此时，需要紧急进行处理，不然一部分流量会一直报错</p>
<ul>
<li>下线OOM的容器：避免流量再路由到该容器，因为该容器已经OOM，已无法对外正常提供服务</li>
<li>启动新的容器：缓解流量压力</li>
</ul>
<h1 id="后续定位"><a href="#后续定位" class="headerlink" title="后续定位"></a>后续定位</h1><p>通过紧急处理后，线上流量恢复正常，但是经过一段时间后(<code>数分钟</code>)，其中的某个容器又因为OOM而无法正常对外提供服务；所以在运维进行节点紧急处理的同时，后端研发立即开始对OOM的产生原因进行排查定位</p>
<h2 id="1、下载dump"><a href="#1、下载dump" class="headerlink" title="1、下载dump"></a>1、下载dump</h2><p>由于服务在启动时，指定了以下参数：</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token parameter variable">-XX:+HeapDumpOnOutOfMemoryError</span> 
<span class="token parameter variable">-XX:HeapDumpPath</span><span class="token operator">=</span>./logs <span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre></div></figure>

<p>所以，立即联系运维查找该容器的<code>dump</code>文件。</p>
<p>找到后发现，该<code>dump</code>达到了8G大小，文件太大，已经没法下载到本地，通过笔记本进行dump分析了。</p>
<p>所以选择将dump压缩，上传至一台内存大的空闲服务器上，进行dump分析</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token function">tar</span> zcf /data/java_pid1.tar.gz  java_pid1.hprof<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></div></figure>



<h2 id="2、使用MAT分析"><a href="#2、使用MAT分析" class="headerlink" title="2、使用MAT分析"></a>2、使用MAT分析</h2><p>由于生产环境是在运维的协助下进行了，开发同学是没有操作权限的，所以下文我在windows的wsl系统中进行演示</p>
<p>MAT(Memory Analyzer Tool)：是一个基于Eclipse的内存分析工具，可帮助我们查找内存泄漏、减少内存消耗</p>
<p>1、首先需要在服务器上安装MAT：</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token comment"># 方法1、可以选择下载好后，上传至服务器</span>
下载地址：http://www.eclipse.org/mat/downloads.php

<span class="token comment"># 方法2、可以直接在服务器上下载</span>
root@6d1f8b7a9da4:/<span class="token comment"># curl -O https://ftp.yz.yamagata-u.ac.jp/pub/eclipse//mat/1.12.0/rcp/MemoryAnalyzer-1.12.0.20210602-linux.gtk.x86_64.zip</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>

<img src="/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/Snipaste_2022-06-06_19-17-24.png" srcset="/img/loading.gif" lazyload alt="Snipaste_2022-06-06_19-17-24" style="zoom:80%;"> 

<p><b></b></p>
<p>2、解压：</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">mdw@LAPTOP-BEJAL8K9:/mnt/d/wsl/mat$ <span class="token function">unzip</span> MemoryAnalyzer-1.12.0.20210602-linux.gtk.x86_64.zip<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></div></figure>

<p>3、配置文件：如果dump文件太大，则需修改配置文件(<code>MemoryAnalyzer.ini</code>)</p>
<img src="/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/Snipaste_2023-06-26_17-45-10.png" srcset="/img/loading.gif" lazyload alt="Snipaste_2023-06-26_17-45-10" style="zoom:67%;"> 

<figure><div class="code-wrapper"><pre class="line-numbers language-sql" data-language="sql"><code class="language-sql"><span class="token comment"># MemoryAnalyzer.ini</span>
<span class="token operator">-</span>startup
plugins<span class="token operator">/</span>org<span class="token punctuation">.</span>eclipse<span class="token punctuation">.</span>equinox<span class="token punctuation">.</span>launcher_1<span class="token punctuation">.</span><span class="token number">6.200</span><span class="token punctuation">.</span>v20210416<span class="token operator">-</span><span class="token number">2027.</span>jar
<span class="token comment">--launcher.library</span>
plugins<span class="token operator">/</span>org<span class="token punctuation">.</span>eclipse<span class="token punctuation">.</span>equinox<span class="token punctuation">.</span>launcher<span class="token punctuation">.</span>gtk<span class="token punctuation">.</span>linux<span class="token punctuation">.</span>x86_64_1<span class="token punctuation">.</span><span class="token number">2.200</span><span class="token punctuation">.</span>v20210429<span class="token operator">-</span><span class="token number">1609</span>
<span class="token operator">-</span>vmargs
<span class="token operator">-</span>Xmx1024m <span class="token comment"># 若在后续操作中出现报错为heap space，而停止分析，说明堆内存小了，改它</span>
<span class="token operator">-</span>DhprofStrictnessWarning<span class="token operator">=</span><span class="token boolean">true</span>  <span class="token comment"># 最好加上，防止因为某些不必要的提示停止分析</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>

<p>4、开始分析：</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token comment"># 1、切换到sh命令目录</span>
<span class="token builtin class-name">cd</span> /mnt/d/wsl/soft/mat/mat

<span class="token comment"># 2、执行MAT命令：\后面不能有空格</span>
./ParseHeapDump.sh <span class="token punctuation">\</span>
    /mnt/d/wsl/dump/java_pid106068.hprof  <span class="token punctuation">\</span> 
    org.eclipse.mat.api:suspects <span class="token punctuation">\</span>
    org.eclipse.mat.api:overview <span class="token punctuation">\</span>
    org.eclipse.mat.api:top_components
    
-- 参数：可选择分析三者中的任意几个任务    
    - suspects：生成xxx_Leak_Suspects.zip分析报告
    			泄漏嫌疑报告：包含了由MAT识别出的，潜在内存泄漏嫌疑对象的详细信息
    - overview：生成xxx_System_Overview.zip分析报告
    			系统概览报告：堆转储文件的系统概览信息，用于全面了解系统的内存使用情况和分布
    			             包含了各种内存指标、GC活动、线程、类加载等系统级别的信息
    - op_componets：生成xxx_Top_Components.zip分析报告
                 最大对象组件报告：包含了堆转储文件中最大的对象组件<span class="token punctuation">(</span>一组相互引用的对象<span class="token punctuation">)</span>的信息
                                 通过此报告，可了解占用内存最多的对象之间的关系<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>

<img src="/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/Snipaste_2023-06-21_18-14-31.png" srcset="/img/loading.gif" lazyload alt="Snipaste_2023-06-21_18-14-31" style="zoom:70%;"> 

<p><b></b></p>
<p>5、输出结果：</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">输出目录：分析文件、临时文件，会输出到dump文件目录下	
输出文件：	
  <span class="token number">3</span>份zpi文件：
    <span class="token punctuation">[</span>dump文件名<span class="token punctuation">]</span>_Leak_Suspects.zip
    <span class="token punctuation">[</span>dump文件名<span class="token punctuation">]</span>_System_Overview.zip
    <span class="token punctuation">[</span>dump文件名<span class="token punctuation">]</span>_Top_Components.zip
  临时文件：包含.index 结尾的索引文件，首次分析会建立索引速度较慢，后续再执行其他任务就很快了<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>

<img src="/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/Snipaste_2022-06-06_20-56-02.png" srcset="/img/loading.gif" lazyload alt="Snipaste_2022-06-06_20-56-02" style="zoom:80%;">

<p> <b></b></p>
<p>6、查看分析报告：将.zip下载到本地，分别解压，双击<code>index.html</code>使用浏览器查看</p>
<p>○ 泄漏嫌疑报告：这里基本就已经破案了</p>
<img src="/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/Snipaste_2022-06-06_21-25-00.png" srcset="/img/loading.gif" lazyload alt="Snipaste_2022-06-06_21-25-00" style="zoom:80%;"> 

<p><b></b></p>
<p>○ 系统概览报告：通过查看我们自己的包名，能看到是哪个对象占用了大量堆内存</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">在上述的生产OOM中，dump分析完成的系统概览报告中：
	某个对象<span class="token punctuation">(</span>数据库结果集<span class="token punctuation">)</span>，数据量达到了1000W+
明显是查询数据库，where条件缺失导致，进而定位到了引发OOM的真凶<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span></span></code></pre></div></figure>

<img src="/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/Snipaste_2022-06-06_21-27-14.png" srcset="/img/loading.gif" lazyload alt="Snipaste_2022-06-06_21-27-14" style="zoom:80%;"> 





<h2 id="3、遇到的问题"><a href="#3、遇到的问题" class="headerlink" title="3、遇到的问题"></a>3、遇到的问题</h2><p>在<a href="#2%E3%80%81%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90">使用MAT分析</a>的步骤4中，遇到了几个报错</p>
<ol>
<li><p>只支持JDK11以上：需要在服务器上安装JDK11，并在MAT的配置文件中指定</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">mat Version <span class="token number">1.8</span>.0_131 of the JVM is not suitable <span class="token keyword">for</span> this product. Version: <span class="token number">11</span> or greater is required<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre></div></figure>

<figure><div class="code-wrapper"><pre class="line-numbers language-properties" data-language="properties"><code class="language-properties"><span class="token comment"># MemoryAnalyzer(mat) 内存分析工具报错version1.8.0 of the jvm is not suitable for this product 11</span>
<span class="token key attr-name">https</span><span class="token punctuation">:</span><span class="token value attr-value">//blog.csdn.net/health7788/article/details/123893540</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre></div></figure>

<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token comment"># 1、修改配置文件：MemoryAnalyzer.ini</span>
<span class="token parameter variable">-startup</span>
plugins/org.eclipse.equinox.launcher_1.6.200.v20210416-2027.jar
<span class="token parameter variable">--launcher.library</span>
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.2.200.v20210429-1609
<span class="token parameter variable">-vm</span>									<span class="token comment"># 增加</span>
/mnt/c/JDK/jdk-11.0.15.1/bin/java	   <span class="token comment"># 增加</span>
<span class="token parameter variable">-vmargs</span>
<span class="token parameter variable">-Xmx1024m</span>
<span class="token parameter variable">-DhprofStrictnessWarning</span><span class="token operator">=</span>true

<span class="token comment"># 2、重新执行</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure>
</li>
<li><p>命令换行中带了空格，导致分析结果里没有zip文件：</p>
<img src="/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/Snipaste_2023-06-21_17-41-13.png" srcset="/img/loading.gif" lazyload alt="Snipaste_2023-06-21_17-41-13" style="zoom:70%;"> 

<p><b></b></p>
<img src="/2023/02/25/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D%EF%BC%9A%E4%BD%BF%E7%94%A8MAT%E5%88%86%E6%9E%90OOM%E5%BC%82%E5%B8%B8/Snipaste_2023-06-21_18-09-25.png" srcset="/img/loading.gif" lazyload alt="Snipaste_2023-06-21_18-09-25" style="zoom:80%;">

<p>3、MAT配置的堆内存太小，分析完成，但是没有出现预期的分析结果文件：</p>
<figure><div class="code-wrapper"><pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token comment"># 原因</span>
MAT的配置文件MemoryAnalyzer.ini中指定了堆内存最大值：Xmx1024m
但我们的dump文件太大了<span class="token punctuation">(</span>8G<span class="token punctuation">)</span>，所以分析中断了

<span class="token comment"># 解决：将MemoryAnalyzer.ini的Xmx参数调整为20G</span>
Xmx20g
  <span class="token operator">==</span><span class="token operator">></span> 调整后，在经过了十几分钟的分析后，指定目录出现了分析结果文件<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre></div></figure></li>
</ol>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E5%BC%82%E5%B8%B8%E5%AE%9A%E4%BD%8D/" class="category-chain-item">异常定位</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/MAT/" class="print-no-link">#MAT</a>
      
        <a href="/tags/OOM/" class="print-no-link">#OOM</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>异常定位：使用MAT分析OOM异常</div>
      <div>http://example.com/2023/02/25/异常定位：使用MAT分析OOM异常/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>XiaoMaDing</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2023年2月25日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a class="print-no-link" target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2023/03/12/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98%EF%BC%9A%E4%BC%98%E9%9B%85%E7%9A%84%E8%BF%9B%E8%A1%8CFeign%E6%9C%AC%E5%9C%B0%E8%B0%83%E8%AF%95/" title="项目实战：优雅的进行Feign本地调试">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">项目实战：优雅的进行Feign本地调试</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2023/02/08/%E9%A1%B9%E7%9B%AE%E5%AE%9E%E6%88%98%EF%BC%9A%E7%AD%96%E7%95%A5%E4%B8%8E%E8%B4%A3%E4%BB%BB%E9%93%BE%E6%A8%A1%E5%BC%8F%E5%9C%A8%E9%A1%B9%E7%9B%AE%E4%B8%AD%E7%9A%84%E5%BA%94%E7%94%A8/" title="项目实战：策略与责任链模式在项目中的应用">
                        <span class="hidden-mobile">项目实战：策略与责任链模式在项目中的应用</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  
  
    <article id="comments" lazyload>
      
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"fwhgdRnxBMBQuwXd6G2KY7uA-gzGzoHsz","appKey":"wz9qgHwvuMw8Y0yXAvL1KEr4","path":"window.location.pathname","placeholder":null,"avatar":"retro","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":false,"recordIP":false,"serverURLs":"","emojiCDN":null,"emojiMaps":null,"enableQQ":false},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


    </article>
  


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script  src="https://lib.baomitu.com/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js" ></script>

  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
